<?php

namespace app\controller\system;

use app\BaseController;
use app\model\StationBasic;
use think\response\Json;

class Area extends BaseController
{
    public function tree(): Json
    {
        return $this->handle(function () {
            return $this->app->make(\app\model\Area::class)->tree("100000");
        });
    }

    public function province(): Json
    {
        return $this->handle(function () {
            return $this->app->make(\app\model\Area::class)->province();
        });
    }

    public function city()
    {
        return $this->handle(function () {
            return $this->app->make(\app\model\Area::class)->city();
        });
    }

    public function gasProvince(): Json
    {
        return $this->handle(function () {
            $gas = $this->app->make(StationBasic::class)->group('province_id')->column("province_id");
            return $this->app->make(\app\model\Area::class)->whereIn('adcode', $gas)->column("id,name,adcode");
        });
    }
}
